/******************************************************************************
 * (C) Copyright 
 * FILE NAME:    sys_task.c
 * DESCRIPTION:
 * 
 * DATE BEGUN:   
 * BY:           
 * PRODUCT NAME:
 * APPLICATION:
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

/*****************************************************************************
** #include 
*****************************************************************************/
#include "system.h"
#include "sys_task.h"
#include "sys_iniHW_head.h"
//#include "sys_sleep.h"
#include "sys_scheduler.h"
#include "drv_can.h"
#include "hwa_inputs.h"
#include "diag.h"
//#include "app_debug.h"
//#include "sys_iniAppl_head.h"

//#include "hwa_outputs.h"
//#include "hwa_tle6208.h"

/*****************************************************************************
** #define
*****************************************************************************/
//#define CYCLE_DEB_REQUIRED	(1) /*10ms*1*/
//#define CYCLE_DEB_IDLE      (10)/*10ms*10*/

/*****************************************************************************
** typedef
*****************************************************************************/


/*****************************************************************************
** global variable
*****************************************************************************/
UINT8 readADn;


/*****************************************************************************
** static variables
*****************************************************************************/


/*****************************************************************************
** static constants
*****************************************************************************/


/*****************************************************************************
** static function prototypes
*****************************************************************************/
static void tasksCycle100ms( void );
static void tasksCycle1s( void );
static void tasksCycle10s( void );

/*****************************************************************************
** function prototypes
*****************************************************************************/


/****************************************************************************/
/**
 * Function Name: tasksCycle1ms
 * Description: scheduler 1ms
 *
 * Param:   none
 * Return:  none
 * Author:  2015/12/18, hui.pang create this function
 ****************************************************************************/
void tasksCycle1ms(void)
{
    hwa_e2Handler1ms();
//    app_windowsStallCaptureHandler1ms();
	drv_sci1SendHandler();

    
}

/****************************************************************************/
/**
 * Function Name: tasksCycle2ms
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  
 ****************************************************************************/
void tasksCycle2ms( void )
{

}

/****************************************************************************/
/**
 * Function Name: tasksCycle4ms
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  
 ****************************************************************************/
void tasksCycle4ms( void )
{

}

/****************************************************************************/
/**
 * Function Name: tasksCycle10ms
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  
 ****************************************************************************/
void tasksCycle10ms( void )
{
    UdsAppl_Handler10ms();
    tasksCycle100ms();
    Comm_can1_vHandler10ms();
//    Comm_lin1_vHandler10ms();
	Comm_sci1_vHandler10ms();
	readInputs();
	diagHandler();
    //drv_can_e_test(); //DY
    app_debug_v_InputsByCan();

}

/****************************************************************************/
/**
 * Function Name: tasksCycle100ms
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2014/08/01, hui.pang create this function
 ****************************************************************************/
static void tasksCycle100ms( void )
{
//	UINT8 u8_Data[8] = {0XAA,0X75,0X0E,0X02,0X01,0X00,0X30,0XD5};
    static UINT8 counterCycle3 = 0;

    switch (counterCycle3++)
    {
        /* first 100ms task starts 100ms after scheduler */
    case 0:
//        drv_sciSendFrame(u8_Data);
        break;
    case 1:
    	break;
    case 2:
        break;
    case 3:
        break;
    case 4:
        break;
    case 5:
        break;
    case 6:
        break;
    case 7:
        break;
    case 8:
        break;
    case 9:
        /* scheduler tasks */
        counterCycle3 = 0;
        tasksCycle1s();
        break;
    default:
        counterCycle3 = 0;
        /* scheduler tasks */
//        RESET_SYSTEM();
        break;
    }

}

/****************************************************************************/
/**
 * Function Name: tasksCycle1s
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2014/08/01, hui.pang create this function
 ****************************************************************************/
static void tasksCycle1s( void )
{
    static UINT8 counterCycle4 = 0;

    switch (counterCycle4++)
    {
        /* first 1000ms task starts 1000ms after scheduler */
        case 0:
            break;
        case 1:
            break;
        case 2:
//            app_doorLock_v_Handler1s();
            break;
        case 3:
           // hwa_Outpue_v_Handler1s();
            break;
        case 4:
            break;
        case 5:
            //Sys_SleepHandler1s();
            break;
        case 6:
            break;
        case 7:
            break;
        case 8:
            break;
        case 9:
            counterCycle4 = 0;
            tasksCycle10s();
            break;
        default:
            /* scheduler tasks */
//            drv_watchDogReset();
			counterCycle4 = 0;
            break;
    }
}

/****************************************************************************/
/**
 * Function Name: tasksCycle10s
 * Description: none
 *
 * Param:   none
 * Return:  none
 * Author:  2014/08/01, hui.pang create this function
 ****************************************************************************/
static void tasksCycle10s( void )
{
    static UINT8 counterCycle5 = 0;

    switch (counterCycle5++)
    {
        case 0:
            break;
        case 1:
            break;
        case 2:
            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        case 6:
            break;
        case 7:
            break;
        case 8:
            break;
        case 9:
            counterCycle5 = 0;
            break;
        default:
            /* scheduler tasks */
//            drv_watchDogReset();
			counterCycle5 = 0;
            break;
    }
}

/*****************************************************************************
** End File
*****************************************************************************/

